﻿using MiniFox.Components;
using MiniFox.Infrastructure;
using MiniFox.Platform.OAuth2.Configurations;
using MiniFox.Platform.OAuth2.Events;
using MiniFox.Platform.OAuth2.Services;

namespace MiniFox.Platform.OAuth2
{
    /// <summary>
    /// 
    /// </summary>
    [AutoRegister, SpareComponent(typeof(AuthorizationService))]
    public interface IAuthorizationService
    {
        /// <summary>
        /// 
        /// </summary>
        AuthorizationConfiguration Configuration { get; }
        /// <summary>
        /// 客户端接入检查
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="redirectUri"></param>
        void CheckClient(string appId, string redirectUri);
        /// <summary>
        /// 授权码模式创建授权数据
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="redirectUri"></param>
        /// <param name="context"></param>
        /// <param name="scope"></param>
        /// <returns></returns>
        RedirectResponse CreateAuthorizeData(string appId, string redirectUri, string context, AuthScope scope);
        /// <summary>
        /// 退出登录, 清除登录状态后，返回指定地址（默认情况下，返回指定地址后，由于认证中心登录状态被清除，这将导致重定向到登录页）
        /// </summary>
        /// <param name="redirectUri"></param>
        /// <returns></returns>
        RedirectResponse SignOut(string redirectUri);
        /// <summary>
        /// 
        /// </summary>
        event EventHandler<SignOutEventArgs> SignOutEvent;
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="oldPwd"></param>
        /// <param name="newPwd"></param>
        /// <returns></returns>
        bool ChangePassword(string oldPwd, string newPwd);
    }
}